/*
 *  $Id: DeadlyCold.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Water.Spells {
    public class DeadlyCold: SelfEnchantmentCard {
        public DeadlyCold(): base("001_w_s_deadly_cold") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Water;
            Value = 100;
            AddManaCost(ElementType.Water, 4);
        }

        protected override EnchantmentAffect CreateEnchantment() {
            return new DeadlyColdAffect();
        }

        private class DeadlyColdAffect: EnchantmentAffect<DeadlyCold> {
            public DeadlyColdAffect() {
                Add(new TimeAffect(4));
            }

            public override void SetAffect() {
                base.SetAffect();
                GlobalSummary.OnOffenceReady += DoReady;
                GlobalSummary.OnDefenceReady += DoReady;
                EnemySummary.OnOffenceReady += DoReady;
                EnemySummary.OnDefenceReady += DoReady;
            }
            public override void ResetAffect() {
                base.ResetAffect();
                GlobalSummary.OnOffenceReady -= DoReady;
                GlobalSummary.OnDefenceReady -= DoReady;
                EnemySummary.OnOffenceReady -= DoReady;
                EnemySummary.OnDefenceReady -= DoReady;
            }

            private void DoReady(Creature cr) {
                cr.DamageBy(NewDamage(DamageType.MagicAttack, (cr.MaxHealth+1)/2));
            }
        }
    }
}
